package com.rzl.expense.web.controller.expense.twr;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.rzl.expense.common.utils.DateUtils;
import com.rzl.expense.common.utils.poi.ExcelUtil;
import com.rzl.expense.expense.domain.twr.TwrHighTower;
import com.rzl.expense.expense.domain.twr.TwrHighTowerSummary;
import com.rzl.expense.expense.service.twr.ITwrHighTowerService;
import com.rzl.expense.expense.service.twr.ITwrHighTowerSummaryService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rzl.expense.common.annotation.Log;
import com.rzl.expense.common.core.controller.BaseController;
import com.rzl.expense.common.core.domain.AjaxResult;
import com.rzl.expense.common.enums.BusinessType;
import com.rzl.expense.common.core.page.TableDataInfo;

/**
 * 铁塔-高价塔占比分析
 * Controller
 * @author 董涛
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/twr/high/tower")
public class TwrHighTowerController extends BaseController {
    @Autowired
    private ITwrHighTowerService twrHighTowerService;

    @Autowired
    private ITwrHighTowerSummaryService twrHighTowerSummaryService;

    /**
     * 查询铁塔-高价塔占比分析列表
     */
    @PreAuthorize("@ss.hasPermi('twr:high:tower:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwrHighTower twrHighTower) {
        startPage();
        List<TwrHighTower> list = twrHighTowerService.selectTwrHighTowerList(twrHighTower);
        return getDataTable(list);
    }

    /**
     * 导出铁塔-高价塔占比分析列表
     */
    @PreAuthorize("@ss.hasPermi('twr:high:tower:export')")
    @Log(title = "铁塔-高价塔占比分析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwrHighTower twrHighTower) {
        List<TwrHighTower> list = twrHighTowerService.selectTwrHighTowerList(twrHighTower);
        ExcelUtil<TwrHighTower> util = new ExcelUtil<TwrHighTower>(TwrHighTower.class);
        util.exportExcel(response, list, "铁塔-高价塔占比分析数据");
    }

    @Log(title = "铁塔-高价塔占比分析汇总", businessType = BusinessType.DELETE)
    @GetMapping("/summary")
    public TableDataInfo Summary(TwrHighTowerSummary twrHighTowerSummary) {
        List<TwrHighTowerSummary> list = twrHighTowerSummaryService.selectTwrHighTowerSummaryList(twrHighTowerSummary);

        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('twr:high:tower:export')")
    @Log(title = "铁塔-高价塔占比分析", businessType = BusinessType.EXPORT)
    @PostMapping("/summary/export")
    public void summaryExport(HttpServletResponse response, TwrHighTowerSummary twrHighTowerSummary) {
        List<TwrHighTowerSummary> list = twrHighTowerSummaryService.selectTwrHighTowerSummaryList(twrHighTowerSummary);
        ExcelUtil<TwrHighTowerSummary> util = new ExcelUtil<TwrHighTowerSummary>(TwrHighTowerSummary.class);
        util.exportExcel(response, list, "铁塔-高价塔占比分析数据");
    }

    @Log(title = "铁塔-高价塔占比分析全年趋势图", businessType = BusinessType.OTHER)
    @GetMapping("/allYearTrend")
    public TableDataInfo allYearTrend(TwrHighTowerSummary twrHighTowerSummary) {
        if (twrHighTowerSummary.getStaDate() == null) {
            twrHighTowerSummary.setStaDate(DateUtils.getDate());
        }else{
            twrHighTowerSummary.setStaDate(DateUtils.formatDate(twrHighTowerSummary.getStaDate()));
        }
        List<TwrHighTowerSummary> list = twrHighTowerSummaryService.allYearTrend(twrHighTowerSummary);

        return getDataTable(list);
    }


}
